#include<stdio.h>
int Primary(int a)
{
	int m,s=0;
	while (a!=0)
	{
		s=10*s+a%8;
		a=a/8;
	}
	m=s;
	s=0;
	while (m!=0)
	{
		s=10*s+m%10;
		m=m/10;
	}
	return s;
}
int main()
{
	int x,y;
	while(scanf("%d",&y)==1)
	{
		x=Primary(y);
		printf("%d\n",x);
	}
	return 0;
}
